﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using V = Science.Mathematics.VectorCalculus;

namespace VectorCalculus5Ed.Chapter6.Section3
{
    public class Example06
    {
        public Example06()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
        private double a = 1.5;
        public void Compute()
        {
            V.Function.ToLastType<double[], double> f
                = new V.Function.ToLastType<double[], double>(func);
            
            double[] from = { -a, -a, 0.0};
            double[] to = { a, a, a*a };
            V.IntegrationMultiD obj = new V.IntegrationMultiD(f, from, to);
            obj.Compute();
            result += obj.BestEstimation.ToString() + "\r\n";
            obj.NumberOfCall = 1000000;
            obj.Compute();
            result += obj.BestEstimation.ToString() + "\r\n";
            double ans = 2.0 * Math.PI * Math.Pow(a,6.0) / 6.0;
            result += ans.ToString() + "\r\n";
        }
        private double func(double[] x)
        {
            if (x[0] * x[0] + x[1] * x[1] < x[2]) return 0.0;
            else if (x[0] * x[0] + x[1] * x[1] > a * a) return 0.0;
            else return x[0] * x[0] + x[1] * x[1];
        }
    }
}
/* 
11.9328673713418
11.928930107607
11.9282346065987
*/


